﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using System.Diagnostics;

namespace CoolCode.Tests
{
    public  class SQLiteTest
    {
        [Fact]
        public void QueryTest()
        {
            SQLiteTestDB context = new SQLiteTestDB();             
            var list=  context.Author.OrderBy(c=>c.ID ).Skip(10).Take(3).ToList();
            Assert.Equal(list.Count, 3);
        }

        [Fact]
        public void InsertTest()
        {
            SQLiteTestDB context = new SQLiteTestDB();
            Stopwatch watcher = new Stopwatch();
            watcher.Start();
            for (int i = 0; i < 3000; i++)
            {
                context.AddObject(typeof(Author).Name, new Author
                {
                    ID = i + 60,
                    FirstName = "Bruce" + i,
                    LastName = "Lee" + i
                });
            }
            context.SaveChanges();
            watcher.Stop();
            Debug.WriteLine("TimeSpan:" + watcher.Elapsed);
        }
    }
}
